home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / vesatp11 / example / twocurvs.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-05-16  |  1.6 KB  |  77 lines

  1. {$X+}
  2. PROGRAM twoCurves;
  3.  
  4.     { Draw joined Bezier curves }
  5.  
  6. USES
  7.     VGraph, Crt;
  8.  
  9. CONST
  10.     lastPoint = 4;                             { highest subscript used }
  11.  
  12. VAR
  13.     a, b         : Array[0..LastPoint] of PointType;
  14.     errorCode, n : INTEGER;
  15.  
  16. PROCEDURE initPoints;
  17. VAR
  18.     n, j : INTEGER;
  19.  
  20. BEGIN
  21.     a [0].x :=  10;   a [0].y := 110;
  22.     a [1].x :=  10;   a [1].y :=   0;
  23.     a [2].x := 120;   a [2].y :=   0;
  24.     a [3].x := 180;   a [3].y := 110;
  25.     a [4].x := 240;   a [4].y := 110;
  26.  
  27.     b [0].x := 240;   b [0].y := 110;
  28.     b [1].x := 310;   b [1].y := 110;
  29.     b [2].x := 310;   b [2].y :=   0;
  30.     b [3].x := 180;   b [3].y :=   0;
  31.     b [4].x := 120;   b [4].y := 199;
  32. END;
  33.  
  34. BEGIN
  35.  
  36.     InitVesa(V640x480x256);
  37.     { Check to make sure it happened }
  38.     ErrorCode := graphResult;
  39.     IF errorCode <> grOK THEN BEGIN
  40.         WRITELN ('Graphics error ', errorCode);
  41.         WRITELN ('Program cannot run');
  42.         HALT (1);
  43.     END;
  44.  
  45.     { Draw the first hull outline }
  46.     InitPoints;                                  { First initialize control points }
  47.     SetLineStyle (dottedLn, 0, normWidth);
  48.     SetColor (1);
  49.     MoveTo (a [0].x, a [0].y);
  50.     FOR n := 1 TO lastPoint DO
  51.         LineTo (a [n].x, a [n].y);
  52.  
  53.     { Draw the second hull }
  54.     MoveTo (b [0].x, b [0].y);
  55.     FOR n := 1 TO lastPoint DO
  56.         LineTo (b [n].x, b [n].y);
  57.  
  58.     { Mark the joint with a vertical line }
  59.     MoveTo (240, 100);
  60.     LineTo (240, 120);
  61.  
  62.     { Now draw the first curve }
  63.     SetLineStyle (solidLn, 0, normWidth);
  64.     SetColor (2);
  65.     DrawBezier(lastPoint,a[1]);
  66.  
  67.     { And second curve }
  68.     SetColor (3);
  69.     DrawBezier(lastPoint,b[1]);
  70.  
  71.     { Clean up after a keypress }
  72.     ReadKey;
  73.     CloseVesa;
  74. END.
  75.  
  76.  
  77.